<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>牧心农业</title>
    <link rel="stylesheet" type="text/css" href="/static/css/eui.css" />
    <link rel="stylesheet" type="text/css" href="/static/css/mobile.css" />
    <link rel="stylesheet" type="text/css" href="/static/css/iconfont.css" />
    <script src="/static/js/jquery.min.js"></script>
    <script src="/static/js/doT.min.js"></script>
    <script src="/static/js/func.js"></script>
</head>
<body>
    <div class="content margin_top_foot">
        <div class="searchbar fixed_top bg_mx_green white"></div>
        <div class="bg_white row padding_h_30 padding_v_10 text_center margin_b_10 lineheight_4">
            <div class="col_4 <{if !$app->request->get('cateid')}>border_b_mx<{/if}>">
                <a href="<{url route='/business/person/pig' }>" <{if !$app->request->get('cateid')}>class="mx_green"<{/if}> >全部</a>
            </div>

            <{foreach from=$cates key=key item=row}>
                <div class="col_4 <{if $row['id']==$app->request->get('cateid')}>border_b_mx<{/if}>">
                    <a href="<{url route='/business/person/pig' cateid=$row['id']}>" <{if $row['id']==$app->request->get('cateid')}>class="mx_green"<{/if}> ><{$row['name']}></a>
                </div>
            <{/foreach}>
        </div>
        <div class="refresh_content">
            <div class="pull_refresh lists bg_white"></div>
            <div class="refresh_load"><div class="refresh_pull_arrow"></div></div>
        </div>
        <div class="sidebar fixed lineheight_4 white hide"></div>
        <footer class="foot_tab fixed_bottom mx_green font_16"></footer>
    </div>
    <div class="toast"></div>
    <!-- toast模版 -->
    <script type="text/template" charset="utf-8" id='toast_template'>
        <i class="iconfont icon-toast{{=it.icon}}"></i>
        <div class="toast_text">{{=it.text}}</div>
    </script>
    <script type="text/template" charset="utf-8" id='nav_template'></script>
    <script type="text/template" charset="utf-8" id='list_template'>
        {{for(var i=0;i<it.length;i++){}}
        <div class="padding_15 border_b v_center" onclick="location.href='{{=it[i].url}}'">
            <div class="width_100">
                <img class="fit_img2" src="{{=it[i].img}}" alt="">
            </div>
            <div class="left_100 padding_l_15">
                <div class="v_center font_12">
                    <div class="left_70">
                        <div><span class="light">编号：</span><span class="mx_green">{{=it[i].no}}</span></div>
                        <div><span class="light">品种：</span><span class="mx_green">{{=it[i].type}}</span></div>
                        <div><span class="light">负责人：</span><span class="mx_green">{{=it[i].owner}}</span></div>
                        <div><span class="light">农户：</span><span class="mx_green">{{=it[i].farmer}}</span></div>
                    </div>
                    <div class="width_70 text_center">
                        <div class="lineheight_3 {{if(it[i].status=="健康成长"){}}mx_green{{}else if(it[i].status=="出栏预警"){}}warning{{}}}">{{=it[i].status}}</div>
                        {{if(it.oldstatus!=1){}}<div class="bg_mx_green border_mx_green circle_5">管理</div>{{}}}
                    </div>
                </div>
            </div>
        </div>
        <input name="_csrf" type="hidden" id="_csrf" value="<{$app->request->csrfToken}>">
        {{}}}
    </script>
    <script>
        // 页面初始化
            var navs = <{$navs}>,lists = <{$lists}>;
            var evalToast = doT.template($("#toast_template").text());
            var evallist = doT.template($("#list_template").text());
            loadsearchbar(function(){
                $(".header_user").show().prev().hide()
            });
            loadsidenav(navs)
            loaddata(".lists",evallist,lists)
            loadbfootbar()
        // 搜索
            $(".content").on("input",".searchbar_input input",function(){
                var that = this;
                var keywords = $(this).val();
                if(keywords){
                    $.post("/business/person/search-pig",{keywords:keywords,_csrf:$('#_csrf').val()},function(res){
                        if(res.status && res.status == 1){
                            toast("attention",res.msg)
                        }else{
                            $(".lists").html(evallist(res))
                        }
                     },"json")
                }
            })
            function search(obj){
                var keywords = $(obj).next().val();
                if(keywords){
                    $.post("/business/person/search-pig",{keywords:keywords,_csrf:$('#_csrf').val()},function(res){
                        if(res.status && res.status == 1){
                            toast("attention",res.msg)
                        }else{
                            $(".lists").html(evallist(res))
                        }
                     },"json")
                }else{
                    toast("attention","请输入搜索关键词",function(){
                        $(obj).next().focus()
                    });
                }
            }
        // 下拉加载更多
            var pindex = 1;
            var pullRefresh = new mobileRefresh({
                container: document.querySelector('.refresh_content'),
                triggerDistance: 100,
                type:"up"
            },function(){
                 $.post("",{pindex:++pindex,_csrf:$('#_csrf').val()},function(res){
                     $(".pull_refresh").append(evallist(res));
                     pullRefresh.cancelLoading();
                 },"json")
            })
    </script>
</body>
</html>
